function [commonNode,closestNode] = getCommonNode(backupPathTable, pathBetweenTwoNodes,closestNode, receiver, matrix, disp_loc) 
      
           commonNode = 0; 
           [neighborsS] = node_neighbors(closestNode,matrix);%This function will return the neighbors for certain node.
           S = length(neighborsS);
           for i = 1:S
              if neighborsS(i) == receiver
                  commonNode = -1;
           end
           if commonNode ~= -1
                  [neighborsR] = node_neighbors(receiver,matrix); 
                   R = length(neighborsR);
                   a = length(backupPathTable);
                   b = length(pathBetweenTwoNodes); 
                   [DBSND]= distanceBetweenSourceAndNeighbors(receiver,neighborsS,disp_loc);
                    [e,f] = sort(DBSND);
                    for num = 1:S
                        sortingNeighbors(1,num) = neighborsS(f(1,num));
                    end
                       test1 = 0;
                       for i = 1 : S
                          if  test1 ~= -1
                               sndNeigh = sortingNeighbors(i);                
                               for j = 1:a
            %                      element = backupPathTable(j);
                                 if sortingNeighbors(i) == backupPathTable(j)
                                    sndNeigh = 0;
                                 end                 
                               end
                                for j = 1:b
            %                         element = pathBetweenTwoNodes(j);
                                    if sndNeigh == pathBetweenTwoNodes(j)
                                        sndNeigh = 0;
                                    end
                                end 

                               if test1 == 0 && sndNeigh ~= 0  
                                     closestNode = sndNeigh;
                                     test1 = -1;
                               end
                          end
                 	end  
                  temp = 0;
                   for q = 1 : R           
                      rcvNeigh = neighborsR(q);

                      if temp == 0
                          if closestNode == rcvNeigh
                              commonNode = closestNode;
                              closestNode = 0;
                              temp = 1;
                          else
                              commonNode = 0;

                          end
                      end
                   end   
           end
end